import { Controller, Post, Body } from '@nestjs/common';
import { DictService } from './dict.service';
import { CreateDictDto, FindDictDto, UpdateDictDto, RemoveDictDto, CreateBatchDictDto, RemoveBatchDictDto } from './dto/dict.dto';
import { Authority } from '@/common/decorators/authority.decorator';
import { useResult } from '@/common/hooks/useResult';

@Controller('dict')
export class DictController {
  constructor(private readonly dictService: DictService) {}

  @Post('create')
  @Authority('dict:create')
  async create(@Body() body: CreateDictDto) {
    const res = await this.dictService.create(body);
    return useResult(res);
  }

  @Post('findAll')
  @Authority('dict:find')
  async findAll(@Body() body: FindDictDto) {
    const res = await this.dictService.findAll(body);
    return useResult(res);
  }

  @Post('findOne')
  @Authority('dict:find')
  async findOne(@Body() body: FindDictDto) {
    const res = await this.dictService.findOne(body);
    return useResult(res);
  }

  @Post('update')
  @Authority('dict:update')
  async update(@Body() body: UpdateDictDto) {
    const res = await this.dictService.update(body);
    return useResult(res);
  }

  @Post('remove')
  @Authority('dict:remove')
  async remove(@Body() body: RemoveDictDto) {
    const res = await this.dictService.remove(body);
    return useResult(res);
  }

  @Post('removeBatch')
  @Authority('dict:remove')
  async removeBatch(@Body() body: RemoveBatchDictDto) {
    const res = await this.dictService.removeBatch(body);
    return useResult(res);
  }

  @Post('createBatch')
  @Authority('dict:create')
  async createBatch(@Body() body: CreateBatchDictDto) {
    const res = await this.dictService.createBatch(body);
    return useResult(res);
  }
}
